<script>
export default {
  name: 'showReg',
  data() {
    return {
      detail: {},
      loading: false
    }
  },
  methods: {
    async fetchCarRegDetail() {
      try {
        this.loading = true
        this.detail = await this.$store.dispatch('carRegisterStore/fetchCarRegDetailAction', this.id)
      } catch (error) {
        this.$message.error(error.message)
      } finally {
        this.loading = false
      }
    }
  },
  computed: {
    id() {
      return this.$route.query.id
    }
  },
  mounted() {
    this.fetchCarRegDetail()
  }
}
</script>

<template>
  <div class="show-reg" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(255,255,255)">
    <el-card class="top" shadow="never">
      <div slot="header" class="clearfix">
        <span>基本信息</span>
      </div>
      <el-row :gutter="20" style="margin: 30px 0">
        <el-col :span="5">
          <span class="label">运输任务编号:</span>
          <span class="value">{{ detail.transportTaskId }}</span>
        </el-col>
        <el-col :span="5">
          <span class="label">车牌号码:</span>
          <span class="value">{{ detail.licensePlate }}</span>
        </el-col>
        <el-col :span="5">
          <span class="label">起始地机构:</span>
          <span class="value">{{ detail.startAgencyName }}</span>
        </el-col>
        <el-col :span="5">
          <span class="label">目的地机构:</span>
          <span class="value">{{ detail.endAgencyName }}</span>
        </el-col>
      </el-row>
      <el-row :gutter="20" style="margin: 30px 0">
        <el-col :span="5">
          <span class="label">出车时间:</span>
          <span class="value">{{ detail.intoStorageTime }}</span>
        </el-col>
        <el-col :span="5">
          <span class="label">回车时间:</span>
          <span class="value">{{ detail.intoStorageTime }}</span>
        </el-col>
        <el-col :span="5">
          <span class="label">司机:</span>
          <span class="value">{{ detail.driverName }}</span>
        </el-col>
      </el-row>
    </el-card>
    <el-card class="bottom" shadow="never">
      <div slot="header" class="clearfix">
        <span>异常信息</span>
      </div>
      <el-row :gutter="20" style="margin: 30px 0">
        <el-col :span="5">
          <span class="label">车辆故障:</span>
          <span class="value">{{ detail.faultType || '无故障' }}</span>
        </el-col>
        <el-col :span="5">
          <span class="label">车辆违章:</span>
          <span class="value">{{ detail.isBreakRules ? '违章' : '无违章' }}</span>
        </el-col>
        <el-col :span="5">
          <span class="label">车辆事故:</span>
          <span class="value">{{ detail.isAccident ? '是' : '无事故' }}</span>
        </el-col>
        <el-col :span="5">
          <span class="label">车辆是否可用:</span>
          <span class="value">{{ detail.isAvailable ? '可用' : '无停用' }}</span>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<style scoped lang="scss">
.show-reg {
  margin: 20px;

  ::v-deep .el-card__header {
    background-color: rgb(248, 250, 255) !important;
  }

  .bottom {
    margin-top: 20px;
  }

  .label {

  }

  .value {
    font-size: 14px;
    color: #818693;

  }

}
</style>
